<?php


namespace Cumulon\Service\History;

use Cumulon\Service\Kernel\BaseClient;

class Client extends BaseClient
{
    /**
     * 列表  日志
     * @param $request
     */
    public function BasicHistory()
    {
        $basic_data = $this->Basic()['request_type'];
        $result = $this->Basic([ 'basic_data'=>$basic_data, 'history_type' => $basic_data['request_type'] ] );
        HttpHistoryPodcast::dispatch(json_encode($result), $this->app['config']->http_history_url);
    }

    /**
     * 基础参数
     * @param $request
     * @return mixed
     */
    public function Basic()
    {
        $request_type = request()->request_type;
        switch ($request_type){
            case "login":
                $request_type_name = '登陆操作';
                break;
            case "logout":
                $request_type_name = '登出操作';
                break;
            default:
                $request_type_name = '';
                break;
        }
        $result['request_type'] = $request_type_name;
        $result['method']       = request()->getMethod();
        $result['ip']           = request()->getClientIp();
        $result['param']        = request()->all();
        $result['time']         = date('Y-m-d',time());
        $result['url']          = request()->getUri();
        $result['pathinto']     = request()->getPathInfo();
        $result['path']         = request()->path();
        $result['routeName']    = request()->route()->getName();
        $result['user_data']    = request()->user();

        return $result;
    }

}